define(["jquery", "easy-admin"], function ($, ea) {
	
	var room_id = $("#room_id").val();

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'dpjz.room_user/index?room_id='+room_id,
        add_url: 'dpjz.room_user/add',
        edit_url: 'dpjz.room_user/edit',
        delete_url: 'dpjz.room_user/delete',
        export_url: 'dpjz.room_user/export',
        modify_url: 'dpjz.room_user/modify',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                toolbar:['refresh', 'delete'],
                cols: [[
                    {type: 'checkbox'},                    {field: 'dpjzUser.nickname', title: '用户',templet:function(d){
                    	if(d.dpjzUser == undefined || d.dpjzUser.avatar == undefined || d.dpjzUser.avatar == ''){
                    		return "无";
                    	}else{
                    		return "<img style='max-width:25px;' src='"+d.dpjzUser.avatar+"'></img>"+d.dpjzUser.nickname;
                    	}
                    }},                    {field: 'qrcode', title: '二维码', templet: ea.table.image, search: false},                    {field: 'score', title: '分数'},                    {field: 'type', search: 'select', selectList: {"1":"收入","2":"支出"}, title: '类型'},                    {field: 'charge', title: '桌位费'},                    {field: 'is_settlement', search: 'select', selectList: ["未结算","已结算"], title: '状态'},                    {field: 'create_time', title: '创建时间'},                    {width: 250, title: '操作', templet: ea.table.tool},
                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };
    return Controller;
});